Near-optimal Algorithms for Explainable k-medians and k-means